package fastjson;

import com.alibaba.fastjson.JSON;
import fastjson.po.MyData;

public class JavaBeanToJsonString {
    public static void main(String[] args) {
        //1-java对象转json字符串
        MyData myData = new MyData();
        myData.setAction("add");
        myData.setId("1");
        myData.setOrdinal(8L);
        myData.setOrganUnitFullName("testJSON");
        myData.setParent("0");
        myData.setSuborderNo("58961");
        String s = JSON.toJSONString(myData);
        System.out.println("toJsonString()方法：s=" + s);
        //输出结果{"action":"add","id":"1","ordinal":8,"organUnitFullName":"testJSON","parent":"0","suborderNo":"58961"}

    }
}
